import bpmProcessInstanceApi from "@/api/declaration/bpm/bpmProcessInstanceApi"
import httpRequest from "@/config/axios/httpRequest"


export const getProcessInstanceMyPage = async (params: any) => {
  return await httpRequest.get(bpmProcessInstanceApi.GetProcessInstanceMyPage, params)
}

export const getProcessInstanceManagerPage = async (params: any) => {
  return await httpRequest.get(bpmProcessInstanceApi.GetProcessInstanceManagerPage, params)
}

export const createProcessInstance = async (data) => {
  return await httpRequest.post(bpmProcessInstanceApi.CreateProcessInstance, data)
}

export const cancelProcessInstanceByStartUser = async (id: number, reason: string) => {
  const data = {
    id: id,
    reason: reason
  }
  return await httpRequest.delete(bpmProcessInstanceApi.CancelProcessInstanceByStartUser, {data})
}

export const cancelProcessInstanceByAdmin = async (id: number, reason: string) => {
  const data = {
    id: id,
    reason: reason
  }
  return await httpRequest.delete(bpmProcessInstanceApi.CancelProcessInstanceByAdmin, {data})
}

export const getProcessInstance = async (id: string) => {
  return await httpRequest.get(bpmProcessInstanceApi.GetProcessInstance, { params: { id } })
}

export const getProcessInstanceCopyPage = async (params: any) => {
  return await httpRequest.get(bpmProcessInstanceApi.GetProcessInstanceCopyPage, params)
}

// 获取审批详情
export const getApprovalDetail = async (params: any) => {
  return await httpRequest.get(bpmProcessInstanceApi.GetApprovalDetail, params)
}

// 获取表单字段权限
export const getFormFieldsPermission = async (params: any) => {
  return await httpRequest.get(bpmProcessInstanceApi.GetFormFieldsPermission, params)
}

// 获取流程实例的 BPMN 模型视图
export const getProcessInstanceBpmnModelView = async (id: string) => {
  return await httpRequest.get(bpmProcessInstanceApi.GetProcessInstanceBpmnModelView, { params: { id } })
}
